package com.tripwego.client.ui.pageAccueil;

import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.tripwego.client.ui.pageAccueil.IHomeView.Presenter;

public class HomeViewImpl extends Composite implements IHomeView {

	private VerticalPanel viewPanel = new VerticalPanel();

	private HomeWidget homeWidget = new HomeWidget();

	private Presenter presenter;

	private EventBus eventBus;

	/**
	 * 
	 */
	public HomeViewImpl() {
		super();

		viewPanel.setStyleName("homePage");

		viewPanel.setWidth("100%");
		viewPanel.setHeight("700px");

		viewPanel.add(homeWidget.asWidget());
		viewPanel.setCellHorizontalAlignment(homeWidget.asWidget(), HasHorizontalAlignment.ALIGN_CENTER);
	}

	@Override
	public Widget asWidget() {
		init();
		return viewPanel;
	}

	@Override
	public void setPresenter(Presenter presenter) {
		this.presenter = presenter;
		this.homeWidget.setPresenter(presenter);
	}

	@Override
	public void setEventBus(EventBus eventBus) {
		this.eventBus = eventBus;
		this.homeWidget.setEventBus(eventBus);
	}

	@Override
	public void init() {
		presenter.initListTrip();
	}
}
